package com.mapbased.cc.valid;

import com.mapbased.wfw.*;
import javax.servlet.http.HttpSession;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: mapbased.com</p>
 *
 * @author chy_hs(Baily)
 * @version 1.0
 */
public class Session
    implements Validator
{
    final String key;
    Session(String[] keys)
    {
        this.key=keys[0];
    }

    /**
     *
     * @param value String
     * @param rc RenderContext
     * @return boolean
     * @todo Implement this com.mapbased.cc.valid.Validator method
     */
    public boolean isValid(String value,RenderContext rc)
    {
        if(value.equals(""))
        {
            return false;
        }
        HttpSession ss=rc.getRequest().getSession(false);
        if(ss == null)
        {
            return false;
        }
        Object o=ss.getAttribute(key);
        return o != null && value.equals(String.valueOf(o));

    }

    public String toString()
    {
        return "与服务器信息不一致.";
    }

}
